﻿//using System;
//using System.Collections.Generic;
//using System.Windows;
//using System.Windows.Input;
//using GameEditor.View.Components;
//using GameEngine.Model;
//using GameEngine.View.Components;
//using PureMVC.Interfaces;
//using PureMVC.Patterns;
//using GameEngine.View;
//using GameEngine;

//namespace GameEditor.View
//{
//    /// <summary>
//    /// Trata do contentor do editor de jogo
//    /// 
//    /// Contem o menu das opcoes do jogo
//    ///     criar levels
//    ///     opcoes genericas de mapa tilesize etc
//    /// Contem o lvl editor
//    ///     Contem World editor
//    ///     Contem Item editor
//    /// Contem o itemcreator
//    /// </summary>
//    /// <typeparam name="ItemView"></typeparam>
//    /// <typeparam name="MyTileMapView"></typeparam>
//    /// <typeparam name="MyWorldEditorView"></typeparam>
//    /// <typeparam name="MyWorldEditorMenuView"></typeparam>
//    /// <typeparam name="MyTileMapMenuView"></typeparam>
//    /// <typeparam name="MyTileMapGeneratorMenuView"></typeparam>
//    /// <typeparam name="MyItemEditorView"></typeparam>
//    /// <typeparam name="WorldView"></typeparam>
//    /// <typeparam name="ItemVOId"></typeparam>
//    /// <typeparam name="MyBaseUIElementType"></typeparam>
//    public class GameEditorMediator<
//        MyGameEditorView,

//        MyGameEditorMenuView,
//        MyLevelEditorMenuView,
//        MyWorldEditorMenuView,
//        MyMapEditorMenuView,
//        MyResourceEditorMenuView,
//        MyViewEditorMenuView,
//        MyShapeEditorMenuView,
//        MyThingTypeEditorMenuView,
//        MyThingEditorMenuView,

//        MyGameView,
//        MyLevelView,
//        MyWorldView,
//        MyMapView,
//        MyThingView,

//        MyBaseUIElementType,
//        MyIdType> : Mediator

//        where MyGameEditorView : class, IGameEditorView<MyGameEditorMenuView, MyLevelEditorMenuView, MyWorldEditorMenuView, MyMapEditorMenuView, MyResourceEditorMenuView, MyViewEditorMenuView,MyShapeEditorMenuView, MyThingTypeEditorMenuView, MyThingEditorMenuView, MyGameView, MyLevelView, MyWorldView, MyMapView, MyThingView, MyBaseUIElementType, MyIdType>

//        where MyGameEditorMenuView : class, IGameEditorMenuView<MyIdType>
//        where MyLevelEditorMenuView : class, ILevelEditorMenuView<MyIdType>
//        where MyWorldEditorMenuView : class, IWorldEditorMenuView<MyIdType>
//        where MyMapEditorMenuView : class, IMapEditorMenuView
//        where MyResourceEditorMenuView : class ,IResourceEditorMenuView<MyIdType>
//        where MyViewEditorMenuView : class, IViewEditorMenuView<MyIdType>
//        where MyShapeEditorMenuView : class, IShapeEditorMenuView<MyIdType>
//        where MyThingTypeEditorMenuView : class, IThingTypeEditorMenuView<MyIdType>
//        where MyThingEditorMenuView : class, IThingEditorMenuView<MyIdType>

//        where MyGameView : class, IGameView<MyIdType, MyLevelView, MyWorldView, MyMapView, MyThingView, MyBaseUIElementType>
//        where MyLevelView : class, ILevelView<MyIdType,MyWorldView, MyMapView, MyThingView, MyBaseUIElementType>
//        where MyWorldView : class, IWorldView<MyIdType, MyMapView, MyThingView, MyBaseUIElementType>
//        where MyMapView : class, IMapView<MyIdType, MyThingView, MyBaseUIElementType>
//        where MyThingView : class, IThingView<MyIdType, MyBaseUIElementType>

//        where MyIdType : IComparable<MyIdType>
//    {
//        //protected GameMediator<MyGameView, MyLevelView, MyWorldView, MyMapView, MyItemView, MyIdType, MyBaseUIElementType> gameMediator;
//        public IGameDataProxy<MyIdType> game { get; protected set; }
//        public WorldMediator<MyWorldView, MyMapView, MyThingView, MyIdType, MyBaseUIElementType> worldMediator { get; protected set; }

//        public GamePropertiesEditor_MenuMediator<MyGameEditorMenuView, MyIdType> gameEditorMenuMediator { get; protected set; }
//        public LevelPropertiesEditor_MenuMediator<MyLevelEditorMenuView, MyIdType> levelEditorMenuMediator { get; protected set; }
//        public WorldPropertiesEditor_MenuMediator<MyWorldEditorMenuView, MyIdType> worldEditorMenuMediator { get; protected set; }
//        public MapPropertiesEditor_Mediator<MyMapEditorMenuView, MyMapView, MyThingView, MyIdType, MyBaseUIElementType> mapEditorMenuMediator { get; protected set; }
//        //protected ResourceEditorMenuMediator<MyResourceEditorMenuView,MyIdType> resourceEditorMenuMediator;
//        //protected ViewEditorMenuMediator<MyViewEditorMenuView, MyIdType> viewEditorMenuMediator;
//        //protected ThingTypeEditorMenuMediator<MyThingTypeEditorMenuView, MyIdType> thingTypeEditorMenuMediator;
//        public ThingPropertiesEditor_MenuMediator<MyThingEditorMenuView, MyIdType> thingEditorMenuMediator { get; protected set; }
//        public string exitCommand{get; protected set;}

//        public GameEditorMediator(string name,
//            MyGameEditorView view,
//            IGameDataProxy<MyIdType> game,
//            WorldMediator<MyWorldView,MyMapView,MyThingView,MyIdType,MyBaseUIElementType> worldMediator,
//            GamePropertiesEditor_MenuMediator<MyGameEditorMenuView, MyIdType> gameEditorMenuMediator, 
//            LevelPropertiesEditor_MenuMediator<MyLevelEditorMenuView, MyIdType> levelEditorMenuMediator,
//            WorldPropertiesEditor_MenuMediator<MyWorldEditorMenuView, MyIdType> worldEditorMenuMediator,
//            MapPropertiesEditor_Mediator<MyMapEditorMenuView, MyMapView, MyThingView, MyIdType, MyBaseUIElementType> mapEditorMenuMediator, 
//            //ResourceEditorMenuMediator<MyResourceEditorMenuView,MyIdType> resourceEditorMenuMediator,
//            //ViewEditorMenuMediator<MyViewEditorMenuView, MyIdType> viewEditorMenuMediator,
//            //ThingTypeEditorMenuMediator<MyThingTypeEditorMenuView, MyIdType> thingTypeEditorMenuMediator,
//            ThingPropertiesEditor_MenuMediator<MyThingEditorMenuView, MyIdType> thingEditorMenuMediator,
//            string exitCommand
//            )
//            : base(name, view)
//        {
//            this.game = game;
//            this.worldMediator = worldMediator;

//            this.gameEditorMenuMediator=gameEditorMenuMediator; 
//            this.levelEditorMenuMediator=levelEditorMenuMediator;
//            this.worldEditorMenuMediator=worldEditorMenuMediator;
//            this.mapEditorMenuMediator=mapEditorMenuMediator;
//            //this.resourceEditorMenuMediator=resourceEditorMenuMediator;
//            //this.viewEditorMenuMediator=viewEditorMenuMediator;
//            //this.thingTypeEditorMenuMediator=thingTypeEditorMenuMediator;
//            this.thingEditorMenuMediator = thingEditorMenuMediator;
//            this.exitCommand = exitCommand;
//        }

//        public new MyGameEditorView ViewComponent
//        {
//            get { return base.ViewComponent as MyGameEditorView; }
//        }

//        #region IMediator Members

//        /// <summary>
//        /// List the <c>INotification</c> names this <c>Mediator</c> is interested in being notified of
//        /// </summary>
//        /// <returns>The list of <c>INotification</c> names </returns>
//        override public IList<string> ListNotificationInterests()
//        {
//            IList<String> notifications = base.ListNotificationInterests();

//            //notifications.Add(gameEditorMenuMediator.SETWORLDPROPERTIES_BUTTONPRESSED);

//            //notifications.Add(mapEditorMenuMediator.TILEMOUSELEFTBUTTONUP);

//            ////notifications.Add(tileMapMenuMediator.SIZECHANGED);

//            //notifications.Add(thingEditorMenuMediator.ADDITEMTOGAME_NOTIFICATION);
//            notifications.Add(MapMediator<MyMapView, MyThingView, MyIdType, MyBaseUIElementType>.ITEMSELECTED);
//            return notifications;
//        }

//        /// <summary>
//        /// Handle <c>INotification</c>s
//        /// </summary>
//        /// <param name="notification">The <c>INotification</c> instance to handle</param>
//        /// <remarks>
//        ///     <para>
//        ///        Typically this will be handled in a switch statement, with one 'case' entry per <c>INotification</c> the <c>Mediator</c> is interested in. 
//        ///     </para>
//        /// </remarks>
//        override public void HandleNotification(INotification notification)
//        {
//            switch (notification.Name)
//            {
//                case MapMediator<MyMapView, MyThingView, MyIdType, MyBaseUIElementType>.ITEMSELECTED:
//                    var thing = notification.Body as IThingDataProxy<MyIdType>;                       
//                    thingEditorMenuMediator.DataProxy = thing;
//                    break;
//                default:

//                    //if (notification.Name.Equals(worldMediator.mapMediator.TILEMOUSELEFTBUTTONUP))
//                    //{
//                    //    Point position = (Point)notification.Body;
//                    //    if (tileMapMenuMediator.TerrainDownButtonPressed)
//                    //    {
//                    //        //TerrainDown(position);
//                    //    }
//                    //    if (tileMapMenuMediator.TerrainUpButtonPressed)
//                    //    {
//                    //        //TerrainUp(position);
//                    //    }
//                    //}
//                    //else if (notification.Name.Equals(tileMapMenuMediator.TERRAINUP_BUTTONPRESSED))
//                    //{
//                    //    if (tileMapMenuMediator.TerrainUpButtonPressed)
//                    //        worldMediator.mapMediator.SetMouseCursor(Cursors.Hand);
//                    //    else
//                    //        worldMediator.mapMediator.SetMouseCursor(Cursors.Arrow);
//                    //}
//                    //else if (notification.Name.Equals(tileMapMenuMediator.TERRAINDOWN_BUTTONPRESSED))
//                    //{
//                    //    if (tileMapMenuMediator.TerrainDownButtonPressed)
//                    //        worldMediator.mapMediator.SetMouseCursor(Cursors.Hand);
//                    //    else
//                    //        worldMediator.mapMediator.SetMouseCursor(Cursors.Arrow);
//                    //}
//                    //else 
                    
//                    //else if (notification.Name.Equals(tileMapMenuMediator.SIZECHANGED))
//                    //{
//                    //    //ViewComponent_OnSizeChanged(new Point());
//                    //}
//                    //else if (notification.Name.Equals(gameEditorMenuMediator.SETWORLDPROPERTIES_BUTTONPRESSED))
//                    //{
//                    //    proxy.MaxHeight = gameMenuMediator.MaxMapHeight;
//                    //    proxy.MinHeight = gameMenuMediator.MinMapHeight;
//                    //    proxy.TileSize = gameMenuMediator.TileSize;
//                    //    proxy.TileHeightUnit = gameMenuMediator.TileHeightUnit;
//                    //}
//                    //if (notification.Name.Equals(thingEditorMenuMediator.ADDITEMTOGAME_NOTIFICATION))
//                    //{
//                    //    game.CurrentLevel.Worlds[levelEditorMenuMediator.SelectedWorld].AddItem(notification.Body as IThingDataProxy<MyIdType>);
//                    //}
//                    break;
//            }
//            base.HandleNotification(notification);
//        }

//        /// <summary>
//        /// Called by the View when the Mediator is registered
//        /// </summary>
//        override public void OnRegister()
//        {
//            ViewComponent.SetWorldEditorMenu(worldEditorMenuMediator.ViewComponent);
//            ViewComponent.SetGameEditorMenu(gameEditorMenuMediator.ViewComponent);
//            ViewComponent.SetLevelEditorMenu(levelEditorMenuMediator.ViewComponent);
            
//            ViewComponent.SetMapEditorMenu(mapEditorMenuMediator.ViewComponent);
//            //ViewComponent.SetViewEditorMenu(viewEditorMenuMediator.ViewComponent);
//            //ViewComponent.SetThingTypeEditorMenu(thingTypeEditorMenuMediator.ViewComponent);
//            ViewComponent.SetThingEditorMenu(thingEditorMenuMediator.ViewComponent);

//            ViewComponent.setWorldView(worldMediator.ViewComponent);

//            //gameMenuMediator.MaxMapHeight = proxy.MaxHeight;
//            //gameMenuMediator.MinMapHeight = proxy.MinHeight;
//            //gameMenuMediator.TileSize = proxy.TileSize;
//            //gameMenuMediator.TileHeightUnit = proxy.TileHeightUnit;

//            //mapEditorMenuMediator.MapSize = game.CurrentLevel.Worlds[levelEditorMenuMediator.SelectedWorld].Map.Size;
//            //mapEditorMenuMediator.MapType = game.CurrentLevel.Worlds[levelEditorMenuMediator.SelectedWorld].Map.MapType;
//            //tileMapMenuMediator.PerlinFrequency = 0.025f;//mais terra 0.005
//            //tileMapMenuMediator.PerlinAmplitude = 1f;//mais no limite
//            //tileMapMenuMediator.PerlinPersistence = 0.5f;//mais suave
//            //tileMapMenuMediator.PerlinOctaves = 2;
//            //tileMapMenuMediator.PerlinSeed = 1;
//            //tileMapMenuMediator.PerlinOrigin = new Point();

//            //itemMenuMediator.

//            //ViewComponent.OnSizeChanged += new Action<Point>(ViewComponent_OnSizeChanged);

//            ViewComponent.OnSaveButtonClick += new Action(ViewComponent_OnSaveButtonClick);
//            ViewComponent.OnExitButtonClick += new Action(ViewComponent_OnExitButtonClick);
//        }

//        /// <summary>
//        /// Called by the View when the Mediator is removed
//        /// </summary>
//        override public void OnRemove()
//        {
//            //Facade.RemoveMediator(mapMediator.MediatorName);
//            //Facade.RemoveMediator(Menu.MediatorName);
//           // Facade.RemoveMediator(MenuBar.MediatorName);
//        }

//        #endregion

//        virtual protected void ViewComponent_OnExitButtonClick()
//        {
//            ApplicationFacade.Instance.SendNotification(GameEditorFacade.EDITORFINISH_COMMAND, game, exitCommand);
//        }

//        virtual protected void ViewComponent_OnSaveButtonClick() { 
//            //TODO fazer save aos mediators
//            int i = 0; 
//            /*game.Name = mediator.Name;
//            gameDataProxy.TileSize = mediator.TileSize;
//            gameDataProxy.MaxHeight = mediator.MaxMapHeight;
//            gameDataProxy.MinHeight = mediator.MinMapHeight;
//            gameDataProxy.TileHeightUnit = mediator.TileHeightUnit;
//            gameDataProxy.Levels.Clear();
//            foreach (var obj in mediator.GetLevels())
//            {
//                gameDataProxy.Levels.Add(obj, SilverlightModelFacade.Helper.GetLevelDataProxy(obj).VO);
//            }
//            gameDataProxy.Views.Clear();
//            foreach (var obj in mediator.GetViews())
//            {
//                gameDataProxy.Views.Add(obj, SilverlightModelFacade.Helper.GetViewDataProxy(obj).VO);
//            }
//            gameDataProxy.ThingTypes.Clear();
//            foreach (var obj in mediator.GetThingTypes())
//            {
//                gameDataProxy.ThingTypes.Add(obj, SilverlightModelFacade.Helper.GetThingTypeDataProxy(obj).VO);
//            }
//            gameDataProxy.Resources.Clear();
//            foreach (var obj in mediator.GetResources())
//            {
//                gameDataProxy.Resources.Add(obj, SilverlightModelFacade.Helper.GetResourceDataProxy(obj).VO);
//            }*/
//        }

//    }
//    /*
//    /// <summary>
//    /// Map generic options
//    /// add/remove lvl
//    /// 
//    /// </summary>
//    /// <typeparam name="MyWorldEditorMenuUC"></typeparam>
//    public class GameEditorMenuMediator<MyWorldEditorMenuUC> : Mediator
//        where MyWorldEditorMenuUC : class, IWorldEditorMenuView
//    {
//        public readonly String SETWORLDPROPERTIES_BUTTONPRESSED = "TileMapEditorMenuMediator_SetWorldProperties_";

//        public GameEditorMenuMediator(string name, MyWorldEditorMenuUC view)
//            : base(name, view)
//        {
//            SETWORLDPROPERTIES_BUTTONPRESSED += name;
//        }

//        public new MyWorldEditorMenuUC ViewComponent
//        {
//            get { return base.ViewComponent as MyWorldEditorMenuUC; }
//        }

//        #region IMediator Members

//        /// <summary>
//        /// List the <c>INotification</c> names this <c>Mediator</c> is interested in being notified of
//        /// </summary>
//        /// <returns>The list of <c>INotification</c> names </returns>
//        override public IList<string> ListNotificationInterests()
//        {
//            return new List<string>()
//            {

//            };
//        }

//        /// <summary>
//        /// Handle <c>INotification</c>s
//        /// </summary>
//        /// <param name="notification">The <c>INotification</c> instance to handle</param>
//        /// <remarks>
//        ///     <para>
//        ///        Typically this will be handled in a switch statement, with one 'case' entry per <c>INotification</c> the <c>Mediator</c> is interested in. 
//        ///     </para>
//        /// </remarks>
//        override public void HandleNotification(INotification notification)
//        {
//            switch (notification.Type)
//            {

//            }

//        }

//        /// <summary>
//        /// Called by the View when the Mediator is registered
//        /// </summary>
//        override public void OnRegister()
//        {
//            ViewComponent.OnMapPropertiesSet += new Action<object>(ViewComponent_OnMapPropertiesSet);
//        }

//        void ViewComponent_OnMapPropertiesSet(object obj)
//        {
//            SendNotification(SETWORLDPROPERTIES_BUTTONPRESSED);
//        }

//        /// <summary>
//        /// Called by the View when the Mediator is removed
//        /// </summary>
//        override public void OnRemove()
//        {

//        }

//        #endregion

//        public float MaxMapHeight
//        {
//            get { return ViewComponent.MaxMapHeight; }
//            set { ViewComponent.MaxMapHeight = value; }
//        }
//        public float MinMapHeight
//        {
//            get { return ViewComponent.MinMapHeight; }
//            set { ViewComponent.MinMapHeight = value; }
//        }
//        public float TileHeightUnit
//        {
//            get { return ViewComponent.TileHeightUnit; }
//            set { ViewComponent.TileHeightUnit = value; }
//        }
//        public Point TileSize
//        {
//            get { return ViewComponent.TileSize; }
//            set { ViewComponent.TileSize = value; }
//        }
//    }*/
//}